#include <iostream>
using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  for (cin >> T; T; T--) {
    int n, r1, p1, s1, r2, p2, s2;

    cin >> n >> r1 >> s1 >> p1 >> r2 >> s2 >> p2;
    {
      int tr1 = r1, tp1 = p1, ts1 = s1, tr2 = r2, tp2 = p2, ts2 = s2;

      int maxs = 0, tmp;

      tmp = min(tr1, ts2);  // rock
      maxs += tmp;
      tr1 -= tmp;
      ts2 -= tmp;
      tmp = min(tr1, tr2);
      tr1 -= tmp;
      tr2 -= tmp;
      tmp = min(tr1, tp2);
      maxs -= tmp;
      tr1 -= tmp;
      tp2 -= tmp;

      tmp = min(tp1, tr2);  // paper
      maxs += tmp;
      tp1 -= tmp;
      tr2 -= tmp;
      tmp = min(tp1, tp2);
      tp1 -= tmp;
      tp2 -= tmp;
      tmp = min(tp1, ts2);
      maxs -= tmp;
      tp1 -= tmp;
      ts2 -= tmp;

      tmp = min(ts1, tp2);  // scissors
      maxs += tmp;
      ts1 -= tmp;
      tp2 -= tmp;
      tmp = min(ts1, ts2);
      ts1 -= tmp;
      ts2 -= tmp;
      tmp = min(ts1, tr2);
      maxs -= tmp;
      ts1 -= tmp;
      tr2 -= tmp;
      cout << maxs << " ";
    }
    {
      int tr1 = r1, tp1 = p1, ts1 = s1, tr2 = r2, tp2 = p2, ts2 = s2;

      int mins = 0, tmp;

      tmp = min(tr1, tp2);  // rock
      mins -= tmp;
      tr1 -= tmp;
      tp2 -= tmp;
      tmp = min(tr1, tr2);
      tr1 -= tmp;
      tr2 -= tmp;
      tmp = min(tr1, ts2);
      mins += tmp;
      tr1 -= tmp;
      ts2 -= tmp;

      tmp = min(tp1, ts2);  // paper
      mins -= tmp;
      tp1 -= tmp;
      ts2 -= tmp;
      tmp = min(tp1, tp2);
      tp1 -= tmp;
      tp2 -= tmp;
      tmp = min(tp1, tr2);
      mins += tmp;
      tp1 -= tmp;
      tr2 -= tmp;

      tmp = min(ts1, tr2);  // scissors
      mins -= tmp;
      ts1 -= tmp;
      tr2 -= tmp;
      tmp = min(ts1, ts2);
      ts1 -= tmp;
      ts2 -= tmp;
      tmp = min(ts1, tp2);
      mins += tmp;
      ts1 -= tmp;
      tp2 -= tmp;
      cout << mins << "\n";
    }
  }
  return 0;
}